import {noPass} from '../../../server/api'
import {debounce} from '../../../server/shake'
Page({

  /**
   * 页面的初始数据
   */
  data: {
      reson1:'',
      reson2:'',
      reson3:'',
      qtreson:'',
      jy:'',
      id:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
      this.setData({id:options.processId,processCode:options.processCode})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  passed: debounce(async function () {
    if( this.data.qtreson == "" && this.data.jy == "")
    {
       wx.showToast({
         title: '最少填写一条原因',
         icon:'none'
       })
    }else
    {
      const params = {
        cause:this.data.qtreson,
        suggestion:this.data.jy,
        processId:this.data.id,
        processCode:this.data.processCode
      }
    const data = await noPass(params)
      if(data.code == 200)
      {
        wx.showToast({
          title: '提交成功',
          icon:'success'
        })
        setTimeout(() => {
          wx.reLaunch({
            url: '../../../subPackagesB/pages/myapproval/myapproval',
          })
        }, 500);
      }
    }
}),
  reject(){
    wx.navigateTo({
      url: '../../../subPackagesB/pages/myapproval/myapproval',
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})